<template>
  <div>
    <div class="list_banner">
      <p>生活随笔</p>
    </div>
    <div class="container">
      <el-row :gutter="20">
        <el-col :span="17" :xs="24" :sm="17">
          <el-card
            class="animated zoomIn article-card"
            style="border-radius: 12px 8px 8px 12px"
            v-for="es in essayList"
            :key="es.id"
          >
            <div class="art_content">
              <div class="picbox">
                <img :src="es.image" alt="" />
              </div>
              <div class="art_content_rt">
                <router-link :to="{ path: `/essaycon/${es.id}` }">
                  <div class="content_title">{{ es.title }}</div>
                </router-link>
                <div class="content_desp">
                  <p>
                    {{ es.content }}
                  </p>
                </div>
                <div class="art_footer">
                  <div class="content_ct">
                    <!-- <span><i class="el-icon-place"></i>{{ es.address }}</span> -->
                    <span
                      ><i class="iconfont iconshijian"></i
                      >{{ es.create_time | dataFormat }}</span
                    >
                  </div>
                  <router-link :to="{ path: `/essaycon/${es.id}` }">
                    <div class="read_more"><span>查看更多</span></div>
                  </router-link>
                </div>
              </div>
            </div>
          </el-card>
        </el-col>
        <el-col :span="7" :xs="24" :sm="7">
          <el-card class="hot_news">
            <h2 class="h_title">最新推荐</h2>
            <div class="article_list">
              <ul v-for="item in recommentList" :key="item.id">
                <router-link :to="{ path: `/essaycon/${item.id}` }">
                  <li>
                    <img :src="item.image" alt="" />
                    <div class="recommen.cntent">
                      <p class="recommen_article_title">{{ item.title }}</p>
                      <span class="recommen_article_createTime">{{
                        item.create_time | dataFormat2
                      }}</span>
                    </div>
                  </li></router-link
                >
              </ul>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </div>
  </div>
</template>
<script>
import { getEssay, getRecomment } from "@/request/api";
export default {
  name: "",
  components: {},
  props: [""],
  data() {
    return {
      totalcount: 100,

      pagenum: 1,
      pagesize: 8,
      essayList: [],
      recommentList: [],
    };
  },
  created() {
    this.getEssayList();
    this.getRecomment();
  },
  mounted() {},
  methods: {
    async getRecomment() {
      const { data: res } = await getRecomment();
      this.recommentList = res.data;
    },
    // 获取列表
    async getEssayList() {
      const { data: res } = await getEssay({
        pagenum: this.pagenum,
        pagesize: this.pagesize,
      });
      console.log(res.data);
      this.essayList = res.data;

      this.totalcount = res.total;
    },
  },
};
</script>
<style lang='less' scoped>
.list_banner {
  background: url("@/assets/image/banner4.jpg") no-repeat;
  background-size: 100% 100%;
  position: relative;
  width: 100%;
  height: 200px;
}
.list_banner p {
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  position: absolute;
  top: 70%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: block;
  padding: 5px 10px;
  border-radius: 5px;
  background: #3333334d;
}
.container {
  margin-top: 15px;
  height: 32em;
  margin-bottom: 100px;
}

.art_content {
  display: flex;
  padding: 15px;
  align-items: center;
  img {
    width: 250px;
    height: 200px;
    border-radius: 5px;
    margin-right: 10px;
  }
}
.art_content_rt {
  display: flex;
  height: 200px;
  flex-direction: column;
  justify-content: space-evenly;
}
.content_title {
  font-size: 25px;
  font-weight: 800;
}
.content_desp p {
  color: #808595;
  font-size: 14px;
  line-height: 24px;
  word-break: break-all;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.art_footer {
  display: flex;
  justify-content: space-between;
  .content_ct {
    font-size: 14px;
    line-height: 24px;
    color: rgb(124, 190, 240);
    span {
      margin-right: 20px;
      line-height: 24px;
    }
  }

  .read_more span {
    background: #12b7de;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    padding: 8px 20px;
    border-radius: 4px;
    width: 80px;
    float: right;
  }
}

.article-card {
  margin: 20px 0;
}
.hot_news {
  border-radius: 3px;
  background: #fff;
  padding: 5px 20px 0;
  margin: 20px 0;
  overflow: hidden;
  position: relative;
}
.h_title {
  line-height: 50px;
  font-size: 22px;
}

.hot_news ul li {
  height: 80px;
  display: flex;
  align-items: center;
}
.hot_news ul li img {
  width: 60px;
  height: 60px;
  margin-right: 10px;
}
.recommen_article_createTime {
  color: rgb(73, 72, 72);
  font-size: 12px;
}
@media only screen and (max-width: 992px) {
  .art_content {
    display: block;
    img {
      height: 150px;
    }
  }
  .content_desp p {
    color: #808595;
    font-size: 14px;
    line-height: 24px;
    word-break: break-all;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .content_title {
    font-size: 20px;
    font-weight: 600;
  }
  .content_ct {
    font-size: 12px;
  }
}
</style>